/**
 * Project hdmap
 * @author shengjialiang
 * @version v1.0
 */


#ifndef _ILAYER_H
#define _ILAYER_H

#include "map_datarender/DataRenderConfig.h"
#include "map_dataset/IDataSet.h"
#include <osgViewer/Viewer>
#include "map_common/ObjectMap.h"
#include "map_dataset/DataType.h"
#include "map_common/IEvent.h"
#include "map_common/IEventHandler.h"

namespace DataRender
{
    class MAP_DATARENDER_EXPORT ILayer : public Common::CObject
    {
    public:
        ILayer();
        
        virtual ~ILayer();

        void setViewer(osgViewer::Viewer* in_pRefViewer);

        osgViewer::Viewer* getViewer();

        DataManager::DataType getLayerType();

        void setDataSet(DataManager::IDataSet* in_pRefDataSet);

        DataManager::IDataSet* getDataSet();

        virtual void setVisible(const bool& in_visible);

        virtual bool getVibible();

		virtual void setVisibleDistance(const double& in_visibleDistance);

		virtual double getVisibleDistance();

        virtual bool load() = 0;

        virtual bool unload() = 0;

		virtual std::string getRenderType();

		virtual void setRenderType(const std::string& in_renderType);

    protected:
        DataManager::IDataSet* mpRefDataSet;
        osgViewer::Viewer* mpRefViewer;
        DataManager::DataType mLayerType;
        bool mVisible;
		std::string mRenderType;
		double mVisibleDistance;
    };

	class MAP_DATARENDER_EXPORT CLayerAddEvent 
		: public Common::IEvent
	{
	public:
		CLayerAddEvent();

		CLayerAddEvent(Common::EventType type);

		virtual ~CLayerAddEvent();
	public:
		ILayer* Layer;
	};

    class MAP_DATARENDER_EXPORT CLayerManager
		: public Common::CObjectMap, public Common::CEventHandlerRegister
    {
    public:
        CLayerManager();

        virtual ~CLayerManager();

        static CLayerManager* instance();

        static void releaseInstance();

        void unloadAllayers();

        void removeAllLayers();

        ILayer* getLayer(const std::string& in_businessType, const DataManager::DataType& in_layerType);

		bool add(const std::string& in_key, Common::CObject* in_pRefObject);
        //void initial();

        //void unInitial();
    };
}
#endif //_ILAYER_H